package com.hwadee.ems.service.impl;

import jakarta.annotation.PostConstruct;

import org.springframework.stereotype.Service;

import com.hwadee.ems.domain.dto.PageQuery;
import com.hwadee.ems.domain.dto.Result;
import com.hwadee.ems.domain.po.Course;
import com.hwadee.ems.domain.vo.CourseVO;
import com.hwadee.ems.mapper.CourseMapper;
import com.hwadee.ems.service.ICourseService;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
 * <p>
 * 课程 服务实现类
 * </p>
 *
 * @author EnosElinsa
 * @since 2024/06/21
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements ICourseService {

    private static ICourseService instance;

    public static ICourseService getInstance() {
        return instance;
    }

    @PostConstruct
    void init() {
        instance = this;
    }

    @Override
    public Result<IPage<CourseVO>> page(PageQuery pageQuery) {
        return Result.ok(page(Page.of(pageQuery.getCurrent(), pageQuery.getSize()), 
            Wrappers.emptyWrapper()).convert(CourseVO::new));
    }
}